<template>
  <div class="full-width-bg">
    <div class="header">
      <div class="container header-inner">
        <div class="logo-area">
          <img src="@/assets/logo.jpg" class="logo" />
          <span class="platform-name">无人机智慧平台</span>
        </div>
        <ul class="nav-list">
          <!-- @click="$emit('nav-change', item)" -->
          <li v-for="(item, i) in navs" :key="item" :class="{ active: activeNav === item }"
            @click="handleNavChange(i, item)">
            {{ item }}
          </li>
        </ul>
        <el-button type="primary" class="login-btn" @click="handleLogin">
          登录
        </el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "BaseHeader",
  props: {
    navs: Array,
    activeNav: String,
  },
  methods: {
    handleNavChange(i, item) {
      console.log(i, item);
      if (i == 0) {
        this.$router.push("/");
      } else if (i == 1) {
        this.$router.push("/news");
      } else if (i == 2) {
        this.$router.push("/questionBank")
      }
      else if (i == 3) {
        this.$router.push("/information");
      }
      else if (i == 4) {
        this.$router.push("/VocationalSkills");
      }
      this.$emit("nav-change", item);
    },
    handleLogin() {
      this.$router.push("/login");
    },
  },
};
</script>
<style scoped>
.container {
  width: 1200px;
  margin: 0 auto;
}

.header {
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  height: 60px;
  line-height: 60px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-area {
  display: flex;
  align-items: center;
}

.logo {
  margin-right: 12px;
  width: 32px;
  height: 32px;
  background: #d8d8d8;
  border-radius: 50%;
}

.platform-name {
  font-size: 16px;
  font-weight: 600;
  color: #222;
}

.nav-list {
  display: flex;
  gap: 40px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-list li {
  font-size: 16px;
  font-weight: 500;
  color: #222;
  cursor: pointer;
  transition: color 0.2s;
}

.nav-list li:nth-child(3) {
  margin-left: 400px;
}

.nav-list li.active,
.nav-list li:hover {
  color: #409eff;
}

.login-btn {
  width: 98px;
  height: 60px;
  background: #1664ff;
  font-size: 16px;
  border-radius: 0;
}
</style>
